
var Ajax = {

    send:function(linkPage, queryString){
        queryString = "AJAX=true&"+queryString;
        $.ajax({
            type:   "GET",
            url         :   linkPage,
            cache       :   false,
            data        :   queryString,
            success     :   function(result) {
                return result;
            }
        });
        return "";
    }

}





document.getElementsByClass=function(className){
    var itemsfound=new Array;
    var elements=document.getElementsByTagName('*');
    for(var i=0;i<elements.length;i++){
        if(elements[i].className==className){
            itemsfound.push(elements[i]);
        }
    }

    return itemsfound;
}

var Size={
    width:0,
    height:0
};

//This class is defined functions in different browser
var SupportFunction={

    //Opacity from 1 to 10
    setOpacity:function(idObj,number){
        var obj=document.getElementById(idObj);
        //Firefox, Chrome, Safari
        if(navigator.appName=="Netscape"){
            obj.style.opacity=number/10;
        }else if(navigator.appName=="Microsoft Internet Explorer"){
            obj.style.filter = "alpha(opacity=" + number*10 + ")";
        }
    },


    setPositionFixed:function(idPopup){
        //Firefox, Chrome, Safari
        var popUp=document.getElementById(idPopup);
        if(navigator.appName=="Netscape"){
            popUp.style.position="fixed";
        }else if(navigator.appName=="Microsoft Internet Explorer"){
            popUp.style.position="fixed";
        }
    },

    getBodySize:function() {
        var myWidth = 0, myHeight = 0;
        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
        Size.width=myWidth;
        Size.height=myHeight;
        return Size;
    },

    getWidth:function(idPopup){
        var popUp=document.getElementById(idPopup);
        return popUp.offsetWidth;
    },

    getHeight:function(idPopup){
        var popUp=document.getElementById(idPopup);
        return popUp.offsetHeight;
    },


    setPosition:function(idObj,leftNum,topNum){
        var obj=document.getElementById(idObj);
        obj.style.left=leftNum+"px";
        obj.style.top=topNum+"px";
    },

    alignCenter:function(idPopup){
        var popUp=document.getElementById(idPopup);
        var sizeBody=SupportFunction.getBodySize();
        var widthScreen=sizeBody.width;
        var heightScreen=sizeBody.height;
        var widthForm=SupportFunction.getWidth(idPopup); //Lay chieu rong form
        var heightForm=SupportFunction.getHeight(idPopup); //Lay chieu cao form
        var leftToa=(widthScreen-widthForm)/2;
        var topToa=(heightScreen-heightForm)/2;
        SupportFunction.setPosition(idPopup,leftToa,topToa);
    }

};


var ObjectProcess={

    getElementsByClass:function(className){
        return document.getElementsByClass(className);
    },

    getFirstElementByClass:function(className){
        return 	document.getElementsByClass(className)[0];
    },

    isNull:function(obj){
        if(obj==null)
            return true;
        return false;
    }


};

var DisplayProcess={
    hideStatus:"none",
    showStatus:"",

    getDisplayStatus:function(className,index){
        return 	document.getElementsByClass(className)[index].style.display;
    },

    setDisplayStatus:function(className,index,displayNew){
        document.getElementsByClass(className)[index].style.display=displayNew;
    },

    setDisplay:function(className,displayNew,index){
        var obj=DisplayProcess;
        var objProcess=ObjectProcess;

        if(index==null){
            var elements=objProcess.getElementsByClass(className);
            var lengthElement=elements.length;
            var i=0;
            while(i<lengthElement){
                obj.setDisplayStatus(className,i,displayNew);
                i++;
            }
        }else{
            obj.setDisplayStatus(className,displayNew,index);
        }
    },

    showAll:function(className){
        var obj=DisplayProcess;
        obj.setDisplay(className,obj.showStatus);
    },

    hideAll:function(className){
        var obj=DisplayProcess;
        obj.setDisplay(className,obj.hideStatus);
    }
};


var IFrameProcess={

    changeIframeSrc:function(idFrame,linkSrc){
        document.getElementById(idFrame).src=linkSrc;
    },

    changeIframeWidth:function(idFrame,widthFrame){
        document.getElementById(idFrame).style.width=widthFrame;
    }

};





var StringProcess={

    isPositiveNumber:function(stringProcess){
        var number="0123456789";

        for(i=0;i<stringProcess.length;i++){
            for(j=0;j<number.length;j++){
                if(number.charAt(j)==stringProcess.charAt(i)){
                    j=number.length;
                }
            }
            if(j!=number.length+1){
                i=stringProcess.length;
            }
        }
        if(i==stringProcess.length+1){
            return false;
        }
        return true;
    },

    trimRight:function(str){
        var length=str.length-1;
		while(length>=0&&str.charAt(length)==' ')
		{
			length--;
		}
		return str.substr(0,length+1);
        return str;
    }

};





